import CommonAPI, { BrandForm } from "@/api/system/common";

export function useBrand(isInit) {
  const brandList = ref([]);
  const params = ref<BrandForm>({
    keyword: "",
  });

  async function getBrand() {
    try {
      const data = await CommonAPI.getBrand(params.value);
      brandList.value = data || [];
    } catch (e) {
      console.log(e);
    }
  }
  onMounted(() => {
    if (isInit) {
      getBrand();
    }
  });

  return {
    params,
    brandList,
  };
}
